﻿<%@ Page Title="" Language="C#" MasterPageFile="BGMasterPage.master" AutoEventWireup="true"
    CodeFile="Remark.aspx.cs" Inherits="Remark" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphHeader" runat="Server">
    <script type="text/javascript">
        var result = null;
    </script>
    <style type="text/css">
        .remarkImg
        {
            width: 150px;
            cursor: pointer;
        }
        .bottom{text-align: right; margin: 5px;}
        .bottom .ui-icon-info{display:inline-block;}
        .bottom div{float:left;}
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphContent" runat="Server">
    <table id="jqGridId">
    </table>
    <div id="pager">
    </div>
    <div class="bottom">
        <div class="InfoMessage" style="height:28px">
            <div class="Icon"></div><div class="Text">非系统管理员只可以删除自己添加的备注！</div>
        </div>
        <div style="float:right;">
            添加图片/文件备注：<asp:FileUpload ID="FileUpload1" runat="server" />
            <asp:Button ID="btnAdd" ClientIDMode="Static" runat="server" Text="添加" OnClick="btnAdd_Click"
                CssClass="fm-button ui-state-default ui-corner-all ui-state-hover" />
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Bottom" runat="Server">
    <script type="text/javascript">
        $(function () { 
        $("#jqGridId").jqGrid({   
        url: "Handler/RemarkHandler.ashx?mode=getDataList&cardid=<%=Request["cardid"] %>",
        editurl:"Handler/RemarkHandler.ashx?mode=edit&cardid=<%=Request["cardid"] %>",
        datatype:"json", //为local时初始化不加载，支持json，xml等   
        mtype: "POST",   shrinkToFit:true,autoload:false,
        colNames:['编号', '备注', '备注人','日期'], //表头   
        colModel:[ //这里会根据index去解析jsonReader中root对象的属性，填充cell   
            {name:'ID', index:'ID', width:55, align:"center",sortable:false,key:true,hidden:true},  
            {name:'Remark', index:'Remark', width:600, sortable:false,editable: true,edittype:"textarea",formatter:remarkFormater,editoptions:{maxlength:"1512",rows:"4",cols:"80"}},   
            {name:'Username', index:'Username', width:60,align:"right", sortable:false,editable: false,edittype:"text",editoptions:{maxlength:"16"}},   
            {name:'RemarkDate', index:'RemarkDate', width:60,align:"right",sortable:true,editable: false},   
        ],   
        width: $(window).width()-40, //数字 & 'auto','100%'   
        height: 'auto',   
        rowNum: 99999, //每页记录数   
//        rowList:[5, 10,50,100], //每页记录数可选列表   
        pager: '#pager', //分页标签divID   
        viewrecords: true, //显示记录数信息，如果这里设置为false,下面的不会显示 recordtext: "第{0}到{1}条, 共{2}条记录", //默认显示为{0}-{1} 共{2}条 scroll: false, //滚动翻页，设置为true时翻页栏将不显示  
        /**这里是排序的默认设置，这些值会根据列表header点击排序时覆盖*/ sortable: false,   
        sortname: "id",   
        sortorder: "desc",   
  
        rownumbers: true, //设置列表显示序号,需要注意在colModel中不能使用rn作为index   
        rownumWidth: 20, //设置显示序号的宽度，默认为25   
        multiselect: true, //多选框   
        multiboxonly: true, //在点击表格row时只支持单选，只有当点击checkbox时才多选，需要multiselect=true是有效   
        prmNames : { //如当前查询实体为ware，这些可以在查询对象的superObject中设定   
            page: "wareDetail.page",   
            rows: "wareDetail.rows",   
            sort: "wareDetail.sidx",   
            order: "wareDetail.sord",   
            search: "wareDetail.search"   
        },   
        jsonReader:{ //server返回Json解析设定   
            root: "list", //对于json中数据列表   
            page: "page",   
            total: "totalPage",   
            records: "totalCount",  
            repeatitems: false,   
        },
        editSubmit : function(response, postdata) 
        { 
        alert("submit");
        return [true,"test"] 
        }
    });   
    var editOptions={ top: 100, left: ($("#jqGridId").width()-500)/2, width: 500,closeOnEscape: true,closeAfterEdit:true, reloadAfterSubmit:true,afterSubmit: function(response, postdata){
        var data = $.parseJSON(response.responseText);
        if(data.Result&&data.Message)$.jqAlert(data.Message);
        return[data.Result,data.Message,data.ID];
    }};
    $("#jqGridId").jqGrid('navGrid','#pager',{edit:false,add:true,del:true,search:false,},editOptions,editOptions,editOptions);//这里设定分页bar显示的信息
    
    });

function remarkFormater (cellvalue, options, rowObject)
{
    switch(rowObject.Type){
        case 0:
            return cellvalue;
        case 1:
            return "<img class='remarkImg' src='RemarkFile/"+cellvalue+"' onclick='window.open(this.src)'/>";
        case 2:
            return "<a href='RemarkFile/"+cellvalue+"' >"+cellvalue+"</a>";
        default:
            return cellvalue;
    }
}

if(result){
    $.jqAlert(result.Message);
}
    </script>
</asp:Content>
